﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;


namespace DiscountCoupon
{
    [DataContract]
    public class CouponItemCard
    {
        
        /// <summary>
        /// 优惠卡ID
        /// </summary>
        [DataMember]
        public Guid CardId { get; set; }
        /// <summary>
        /// 优惠卡地址
        /// </summary>
        [DataMember]
        public string CardUrl
        {
            get;
            set;
        }
        /// <summary>
        /// 缩略图地址
        /// </summary>
        [DataMember]
        public string ThumbUrl
        {
            get;
            set;
        }
        /// <summary>
        /// 优惠卡名称
        /// </summary>
        [DataMember]
        public string CardName { get; set; }
        /// <summary>
        /// 价格
        /// </summary>
        [DataMember]
        public float Price { get; set; }
        /// <summary>
        /// 失效日期
        /// </summary>
        [DataMember]
        public DateTime ExpiredDate { get; set; }
        /// <summary>
        /// 所属品牌
        /// </summary>
        [DataMember]
        public int Seller { get; set; }
        /// <summary>
        /// 品牌名称
        /// </summary>
        [DataMember]
        public string SellerName { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        [DataMember]
        public DateTime CreateTime { get; set; }

        #region -- 扩展属性，格式控制

        public string PriceField
        {
            get { return "￥：" + Price; }
        }
        public string CardNameLimit
        {
            get
            {
                if (CardName != null)
                    return CardName.Length > 23 ? CardName.Substring(0, 22) + ".." : CardName;
                else
                    return string.Empty;
            }
        }
        /// <summary>
        /// 将图片URL 格式为id/xxxx.jpg格式
        /// </summary>
        public string CardUrlExt
        {
            get
            {
                return string.Format("{0}/{1}", CardId, CardUrl);
            }
        }
        #endregion
    }
}